<template>
  <div class="index-bonus sub-margin">
    <!-- <div class="sub-page-title">加分项</div> -->
    <div class="content">
      <div class="search-box">
        <el-menu
          size="small"
          :default-active="activeCode"
          class="search-menu-box"
          mode="horizontal"
          @select="onMenuClick">
          <el-menu-item v-for="(item, key) in menuInfo" :key="key" :index="key">
            {{ item.label }}
          </el-menu-item>
        </el-menu>
      </div>
      <div class="table-con">
        <div class="right-con">
          <BonusOne bonusType="1" :activeTab="menuInfo[activeCode].status" v-if="['add', 'sub'].includes(activeCode)" />
          <BonusTwo :activeTab="menuInfo[activeCode].status" v-else />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import BonusOne from './BonusOne'
import BonusTwo from './BonusTwo'
export default {
  name: 'indexBonus',
  components: { BonusOne, BonusTwo },
  props: {},
  data() {
    return {
      menuInfo: {
        add: {
          label: '加分项录入',
          status: '1',
        },
        sub: {
          label: '减分项录入',
          status: '2',
        },
        add_: {
          label: '加分项审定',
          status: '1',
        },
        sub_: {
          label: '减分项审定',
          status: '2',
        },
      },
      activeCode: 'add',
    }
  },
  watch: {},
  computed: {
    ...mapGetters('role', ['isOtherRole', 'isNormalRole', 'isAdminRole', 'isMainRole', 'isOrgRole', 'isPartRole']),
  },
  created() {},
  mounted() {
    if (this.isOrgRole) {
      this.menuInfo = {
        add: {
          label: '加分项录入',
          status: '1',
        },
        sub: {
          label: '减分项录入',
          status: '2',
        },
      }
    } else if (this.isAdminRole) {
      this.menuInfo = {
        add_: {
          label: '加分项审定',
          status: '1',
        },
        sub_: {
          label: '减分项审定',
          status: '2',
        },
      }
      this.activeCode = 'add_'
    }
  },
  methods: {
    onMenuClick(code) {
      this.activeCode = code
    },
  },
}
</script>
<style lang="scss" scoped>
@import '@styles/layout.scss';
.index-bonus {
  height: 100%;
  .content {
    // height: calc(100% - 78px);
    height: calc(100% - 8px);
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    .search-box {
      width: 100%;
      .el-menu {
        .is-active {
          font-weight: bold;
          font-size: 16px;
        }
      }
    }
    .table-con {
      flex: 1;
      display: flex;
      align-items: stretch;
      // padding: 20px 0;
      height: calc(100% - 50px);
      .left-con {
        width: 300px;
        height: 100%;
        overflow: auto;
        position: relative;
        border-right: 1px solid #e4eaf0;
      }

      .right-con {
        flex: 1;
        width: 100%;
        // max-width: 1200px;
        margin: 0 auto;
        // margin-left: 20px;
        position: relative;
        display: flex;
        flex-direction: column;
      }
    }
  }
}
</style>
